package com.applcn.user.service;

import cn.hutool.core.lang.Assert;
import com.applcn.core.base.Result;
import com.applcn.shop.client.ShopClient;
import com.applcn.shop.dto.ShopInfoDTO;
import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * com.applcn.user.service
 * Description:
 *
 * @author: 大妖怪
 * @date: 2020-03-18 00:41
 */
@Service
@RequiredArgsConstructor
public class CommonService {

    private final ShopClient shopClient;

    /**
     *
     * @param shopId
     */
    protected List<ShopInfoDTO> checkShop(Long shopId){
        Result result = shopClient.listShopByIds(Lists.newArrayList(shopId));
        Assert.isTrue(result.isSuccess(), "查询店铺失败！");
        Assert.notNull(result.getData(), "店铺不存在！");
        return (List<ShopInfoDTO>) result.getData();
    }
}
